/**
 * Created by xlwangar on 2018/5/31.
 */

    var axisLabel = {
        lineStyle: {
            show: true,
            color: '#053A62'
        },
        textStyle: {
            fontSize: 18,
            color: '#357ACC'
        }
    };
    var axisLine = {
        lineStyle: {
            color: '#053A62',
            fontSize: 18,
            width: 0,
        }
    };
    var splitLine = {
        lineStyle: {
            fontSize: 18,
            color: '#053A62'
        }
    };
    
    function initmap(mapdata,max) {
        var map = echarts.init(document.getElementById("map"));
	    $.get('../../js/screen/hubei.json', function (geoJson) {
	        echarts.registerMap('HB', geoJson);
	        map.setOption(option = {
	            title: {
	                text: '',
	                textStyle: {
	                    color: '#00AEEF',
	                    fontWeight: 200,
	                    fontSize:56
	                },
	                x: 'center',
	                y: 40
	            },
	            tooltip: {
	                trigger: 'item',
	                formatter: '{b}<br/>{c} (个)'
	            },
	            visualMap: {
	                min: 0,
	                max: max,
	                realtime: false,
	                calculable: true,
	                x:200,
	                y:'20%',
	                textStyle:{
	                    color:'#fff'
	                },
	                inRange: {
	                    color: ['#194360','#0ca3b1', '#00ffff']
	                }
	            },
	            series: [
	                {
	                    center:[112.17185,31.731877],
	                    zoom:1,
	                    aspectScale:1,
	                    name: '目录提供情况',
	                    type: 'map',
	                    mapType: 'HB', // 自定义扩展图表类型
	                    itemStyle:{
	                        normal:{
	                        	label:{
	                        		show:true,
		                            textStyle: {
		                                color: '#fff',
		                                fontSize:22
		                            }
	                        	}
	                        }, 
	                        emphasis: {// 也是选中样式
	                            borderWidth:1,
	                            borderColor:'transparent',
	                            //areaColor: '#ff0066',
	                            label: {
	                                show: true,
	                                textStyle: {
	                                    color: '#fff',
	                                    fontSize:18
	                                }
	                            }
	                        }
	                    },
	                    data:mapdata
	                }
	            ]
	        });
	    });
    	map.on('click', function (params) {
    	    // 控制台打印数据的名称
    		getcitydataUrl(params.name);
    	});
    }

    function barinit(data1,data2) {
        var barchart = echarts.init(document.getElementById("barchart"));
	    var barchartOption = {
	        color: ['#00aeef'],
	        grid: {
	            x: 20,
	            y: 20,
	            x2: 4,
	            y2: 20,
	            borderWidth: 1,
	            borderColor: '#05345A',
	            containLabel: true,
	        },
	        tooltip: {
	            trigger: 'axis'
	        },
	        calculable: true,
	        xAxis: [
	            {
	                type: 'category',
	                axisTick: {length: 0},
	                splitLine: splitLine,
	                axisLine: axisLine, 
	                axisLabel :{  
	                    interval:0,	//	X轴 连续显示
		                lineStyle: {
		                    show: true,
		                    color: '#053A62'
		                },
		                textStyle: {
		                    fontSize: 18,
		                    color: '#357ACC'
		                }
	                },
	                data: data1
	            }
	        ],
	        yAxis: [
	            {
	                type: 'value',
	                boundaryGap: true,
	                axisTick: {length: 0},
	                splitLine: splitLine,
	                axisLine: axisLine,
	                axisLabel: axisLabel,
	                splitArea: {
	                    show: true,
	                    onGap: true,
	                    areaStyle: {
	                        color: ['rgba(6,29,62,.3)',
	                            'rgba(6,29,62,.3)']
	                    }
	                },
	
	            }
	        ],
	        series: [
	            {
	                name: '库表',
	                type: 'bar',
	                barWidth:16,
	                smooth: true,
	                data:data2	
	            }
	        ]
	    };
	    barchart.setOption(barchartOption);
    } 


    function barinitcitydepart(data1,data2) {
        var barchart = echarts.init(document.getElementById("barchart"));
	    var barchartOption = {
	        color: ['#00aeef'],
	        grid: {
	            x: 20,
	            y: 20,
	            x2: 4,
	            y2: 20,
	            borderWidth: 1,
	            borderColor: '#05345A',
	            containLabel: true,
	        },
	        tooltip: {
	            trigger: 'axis'
	        },
	        calculable: true,
	        dataZoom : {
	            height:10,
	            fillerColor:"rgb(0,139,139)",  //选中范围的填充颜色。 
	            backgroundColor:"rgb(70, 130, 180)",  //组件的背景颜色
	            show : true,
	            realtime : true,
	            start : -10,
	            end : 60,
	            top:"bottom"
	        },
	        xAxis: [
	            {
	                type: 'category',
	                axisTick: {length: 0},
	                splitLine: splitLine,
	                axisLine: axisLine, 
	                axisLabel :{   
		                lineStyle: {
		                    show: true,
		                    color: '#053A62'
		                },
		                textStyle: {
		                    fontSize: 18,
		                    color: '#357ACC'
		                }
	                },
	                data: data1
	            }
	        ],
	        yAxis: [
	            {
	                type: 'value',
	                boundaryGap: true,
	                axisTick: {length: 0},
	                splitLine: splitLine,
	                axisLine: axisLine,
	                axisLabel: axisLabel,
	                splitArea: {
	                    show: true,
	                    onGap: true,
	                    areaStyle: {
	                        color: ['rgba(6,29,62,.3)',
	                            'rgba(6,29,62,.3)']
	                    }
	                },
	
	            }
	        ],
	        series: [
	            {
	                name: '库表',
	                type: 'bar',
	                barWidth:16,
	                smooth: true,
	                data:data2	
	            }
	        ]
	    };
	    barchart.setOption(barchartOption);
    } 
    
    
    function pieinitdata1(maparr) {
        var pie = echarts.init(document.getElementById("pie"));
	    var pieOption = {
	        color: ['#01f6f7', '#00aeef', '#ff0066'],
	        tooltip: {
	            trigger: 'item',
	            formatter: "{a} <br/>{b}: {c} ({d}%)"
	        },
	        series: [
	            {
	            	name: '省直',
	                type: 'pie',
	                radius: ['75%', '90%'],
	                center: ['50%', '50%'],
	                avoidLabelOverlap: false,
	                label: {
	                    normal: {
	                        show: false,
	                        position: 'center'
	                    },
	                    emphasis: {
	                        show: true,
	                        textStyle: {
	                            fontSize: '30',
	                            fontWeight: 'bold'
	                        }
	                    }
	                },
	                labelLine: {
	                    normal: {
	                        show: false
	                    }
	                },
	                data: maparr
	            }
	        ]
	    };
	    pie.setOption(pieOption);
    }

    function pieinitdata2(maparr) {
        var pie = echarts.init(document.getElementById("pie02"));
	    var pieOption = {
	        color: ['#01f6f7', '#00aeef', '#ff0066'],
	        tooltip: {
	            trigger: 'item',
	            formatter: "{a} <br/>{b}: {c} ({d}%)"
	        },
	        series: [
	            {
	            	name: '地市州',
	                type: 'pie',
	                radius: ['75%', '90%'],
	                center: ['50%', '50%'],
	                avoidLabelOverlap: false,
	                label: {
	                    normal: {
	                        show: false,
	                        position: 'center'
	                    },
	                    emphasis: {
	                        show: true,
	                        textStyle: {
	                            fontSize: '30',
	                            fontWeight: 'bold'
	                        }
	                    }
	                },
	                labelLine: {
	                    normal: {
	                        show: false
	                    }
	                },
	                data: maparr
	            }
	        ]
	    };
	    pie.setOption(pieOption);
    }
    
    
    
    

	/*function earchbar1(opt4ydata,opt4sdata1,opt4sdata2) {
		var bar = echarts.init(document.getElementById("bar")); 
		var axisLabel = {
	        lineStyle: {
	            show:true,
	            color: '#053A62'
	        },
	        textStyle: {
	            fontSize: 12,
	            color: '#357ACC'
	        }
	    };
	    var axisLine = {
	        lineStyle: {
	            color: '#053A62',
	            width: 0,
	        }
	    };
	    var splitLine = {
	        lineStyle: {
	            color: '#053A62'
	        }
	    };
	    var barOption = {
	        color: ['#00A6E6'],
	        title: {
	            text: '目录提供情况',
	            textStyle: {
	                color: '#00AEEF',
	                fontWeight: 200,
	                fontSize:56
	            },
	            x: 'center',
	            y: 40
	        },
	        legend:{
	            x:'center',
	            y:130,
	            itemWidth:10,
	            itemHeight:10,
	            data:[{
	                name : '可共享数据',
	                textStyle : {color:'#830A4D'}
	            },{
	                name : '数据项',
	                textStyle : {color:'#036192'}
	            }]
	        },
	        grid: {
	            x:20,
	            y: 160,
	            x2: 44,
	            y2: 30,
	            borderWidth: 1,
	            borderColor:'#05345A',
	            containLabel:true,
	        },
	        tooltip: {
	            trigger: 'axis'
	        },
	        calculable: true,
	        xAxis: [
	            {
	                type: 'value',
	                axisTick:{length:0},
	                textStyle:{
	                    fontSize:12
	                },
	                splitLine: splitLine,
	                axisLine: axisLine,
	                axisLabel: axisLabel
	            }
	        ],
	        yAxis: [
	            {
	                type: 'category',
	                boundaryGap: true,
	                axisTick:{length:0},
	                splitLine: splitLine,
	                axisLine: axisLine,
	                axisLabel: axisLabel,
	                splitArea:{
	                    show:true,
	                    onGap:true,
	                    areaStyle:{
	                        color:['rgba(6,29,62,.3)',
	                            'rgba(6,29,62,.3)']}
	                },
	                data: opt4ydata
	            }
	        ],
	        series: [
	            {
	                name: '可共享数据',
	                type: 'bar',
	                stack: '数据',
	                barWidth: 16,
	                itemStyle: {
	                    normal: {
	                        color: new echarts.graphic.LinearGradient(
	                            0, 0, 0, 1,
	                            [
	                                {offset: 0, color: '#FD0166'},
	                                {offset: 0.5, color: '#BC1B73'},
	                                {offset: 1, color: '#87307E'}
	                            ]
	                        )
	                    }
	                },
	                data: opt4sdata1
	            },
	            {
	                name: '数据项',
	                type: 'bar',
	                stack: '数据',
	                barWidth: 16,
	                itemStyle: {
	                    normal: {
	                        color: new echarts.graphic.LinearGradient(
	                            0, 0, 0, 1,
	                            [
	                                {offset: 0, color: '#00ADEE'},
	                                {offset: 0.5, color: '#0283BC'},
	                                {offset: 1, color: '#036B9C'}
	                            ]
	                        )
	                    }
	                },
	                data: opt4sdata2 
	            }
	        ]
	    };
	    bar.setOption(barOption);
	}*/
	//zjf
	function earchbar(opt4ydata,opt4sdata1,opt4sdata2) {
		var bar = echarts.init(document.getElementById("bar")); 
	    var barOption = {
	    		baseOption : {
	    			title: {
	    	            textStyle: {
	    	                color: '#fff',
	    	                fontSize: 16,
	    	            },
	    	            subtext: '',
	    	        },
	    	        legend: {
	    	            data: ['可共享数据项', '数据项'],
	    	            top: 150,
	    	            right: '45%',
	    	            textStyle: {
	    	                color: '#fff',
	    	            },
	    	        },
	    	        toolbox: {
	    	        	show : false,
	    	            right: 20,
	    	            feature: {
	    	                saveAsImage: {},
	    	                restore: {},
	    	                dataView: {},
	    	                dataZoom: {},
	    	                magicType: {
	    	                    type: ['line', 'bar']
	    	                },
	    	                // brush: {},
	    	            }
	    	        },
	    	        grid: [{
	    	            show: false,
	    	            left: '4%',
	    	            top: 180,
	    	            bottom: 30,
	    	            containLabel: true,
	    	            width: '40%',
	    	        }, {
	    	            show: false,
	    	            left: '50.5%',
	    	            top: 200,
	    	            bottom: 30,
	    	            width: '10%',
	    	        }, {
	    	            show: false,
	    	            right: '4%',
	    	            top: 180,
	    	            bottom: 30,
	    	            containLabel: true,
	    	            width: '40%',
	    	        }, ],
	    	        xAxis: [{
	    	            type: 'value',
	    	            inverse: true,
	    	            axisLine: {
	    	                show: false,
	    	            },
	    	            axisTick: {
	    	                show: false,
	    	            },
	    	            position: 'top',
	    	            axisLabel: {
	    	                show: true,
	    	                textStyle: {
	    	                    color: '#B2B2B2',
	    	                    fontSize: 12,
	    	                },
	    	            },
	    	            splitLine: {
	    	                show: true,
	    	                lineStyle: {
	    	                    color: '#1F2022',
	    	                    width: 1,
	    	                    type: 'solid',
	    	                },
	    	            },
	    	        }, {
	    	            gridIndex: 1,
	    	            show: false,
	    	        }, {
	    	            gridIndex: 2,
	    	            type: 'value',
	    	            axisLine: {
	    	                show: false,
	    	            },
	    	            axisTick: {
	    	                show: false,
	    	            },
	    	            position: 'top',
	    	            axisLabel: {
	    	                show: true,
	    	                textStyle: {
	    	                    color: '#B2B2B2',
	    	                    fontSize: 12,
	    	                },
	    	            },
	    	            splitLine: {
	    	                show: true,
	    	                lineStyle: {
	    	                    color: '#1F2022',
	    	                    width: 1,
	    	                    type: 'solid',
	    	                },
	    	            },
	    	        }, ],
	    	        yAxis: [{
	    	            type: 'category',
	    	            inverse: true,
	    	            position: 'right',
	    	            axisLine: {
	    	                show: false
	    	            },
	    	            axisTick: {
	    	                show: false
	    	            },
	    	            axisLabel: {
	    	                show: false,
	    	                margin: 8,
	    	                textStyle: {
	    	                    color: '#9D9EA0',
	    	                    fontSize: 12,
	    	                },

	    	            },
	    	            data: opt4ydata,
	    	        }, {
	    	            gridIndex: 1,
	    	            type: 'category',
	    	            inverse: true,
	    	            position: 'left',
	    	            axisLine: {
	    	                show: false
	    	            },
	    	            axisTick: {
	    	                show: false
	    	            },
	    	            axisLabel: {
	    	                show: true,
	    	                textStyle: {
	    	                    color: '#9D9EA0',
	    	                    fontSize: 22,
	    	                },

	    	            },
	    	            data: opt4ydata.map(function(value) {
	    	                return {
	    	                    value: value,
	    	                    textStyle: {
	    	                        align: 'center',
	    	                    }
	    	                }
	    	            }),
	    	        }, {
	    	            gridIndex: 2,
	    	            type: 'category',
	    	            inverse: true,
	    	            position: 'left',
	    	            axisLine: {
	    	                show: false
	    	            },
	    	            axisTick: {
	    	                show: false
	    	            },
	    	            axisLabel: {
	    	                show: false,
	    	                textStyle: {
	    	                    color: '#9D9EA0',
	    	                    fontSize: 12,
	    	                },

	    	            },
	    	            data: opt4ydata,
	    	        }, ],
	    	        	series : [
	    	        		{
	    	                    name: '可共享数据项',
	    	                    type: 'bar',
	    	                    barGap: 20,
	    	                    barWidth: 20,
	    	                    label: {
	    	                        normal: {
	    	                            show: true
	    	                        },
	    	                        emphasis: {
	    	                            show: false,
	    	                            position: 'left',
	    	                            offset: [0, 0],
	    	                            textStyle: {
	    	                                color: '#fff',
	    	                                fontSize: 14,
	    	                            },
	    	                        },
	    	                    },
	    	                    itemStyle: {
	    	                        normal: {
	    	                            color: '#659F83',
	    	                        },
	    	                        emphasis: {
	    	                            color: '#08C7AE',
	    	                        },
	    	                    },
	    	                    data: opt4sdata1,
	    	                },
	    	                {
	    	                    name: '数据项',
	    	                    type: 'bar',
	    	                    barGap: 20,
	    	                    barWidth: 20,
	    	                    xAxisIndex: 2,
	    	                    yAxisIndex: 2,
	    	                    label: {
	    	                        normal: {
	    	                            show: true,
	    	                        },
	    	                        emphasis: {
	    	                            show: false,
	    	                            position: 'right',
	    	                            offset: [0, 0],
	    	                            textStyle: {
	    	                                color: '#fff',
	    	                                fontSize: 14,
	    	                            },
	    	                        },
	    	                    },
	    	                    itemStyle: {
	    	                        normal: {
	    	                            color: '#F68989',
	    	                        },
	    	                        emphasis: {
	    	                            color: '#F94646',
	    	                        },
	    	                    },
	    	                    data: opt4sdata2,
	    	                }
	    	        	]
	    		}
	    };
	    bar.setOption(barOption);
	}

//    点击切换
    $("#charttab li").on("click", function () {
        $(this).addClass("active").siblings().removeClass("active")
    })
    $("#charttab1 li").on("click", function () {
        $(this).addClass("active").siblings().removeClass("active")
    })
 